package com.woniu.controller;

import com.woniu.entity.PageResult;
import com.woniu.entity.Result;
import com.woniu.pojo.Magnet;
import com.woniu.pojo.MagnetLog;
import com.woniu.pojo.Pda;
import com.woniu.service.IMagnetLogService;
import com.woniu.vo.MagnetLogQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author long
 * @since 2022-10-13
 */
@RestController
@RequestMapping("/magnet-log")
@Api(tags = "地磁日志")
public class MagnetLogController extends BaseController{
    @Autowired
    private IMagnetLogService magnetLogService;

    @ApiOperation("分页搜索")
    @PostMapping("/search/{currentPage}/{pageSize}")
    public Result search(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody MagnetLogQueryVo magnetLogQueryVo){
        PageResult pageResult = magnetLogService.search(currentPage, pageSize, magnetLogQueryVo);
        return toDataResult(pageResult);
    }

    @ApiOperation("查询所有")
    @GetMapping
    public Result queryAll(){
        List<MagnetLog> magnetLogList = magnetLogService.list();
        return toDataResult(magnetLogList);
    }
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    public Result queryById(@PathVariable Long id){
        MagnetLog magnetLog = magnetLogService.getById(id);
        return toDataResult(magnetLog);
    }
}
